#This script includes the analysis of the conjoint experiment and the descriptive survey for the paper "Legitimizing climate action in democracies" by Lukas Fesenfeld, Christian Freudlsperger, Lennart Kuntze, Karin Ingold

#Script author: Dr. Lukas Fesenfeld, lukas.fesenfeld@gess.ethz.ch

#Set Working Directory##################


#Load Packages###############
library(ggplot2)
library(cregg)
library(plyr)
library("texreg")
library("readxl")

#Load Data###############
load("df_joint.RData")
descriptives_DE = read_excel("Descriptives_Germany_final.xlsx")



#Prepare conjoint data###############

df_joint$Support=revalue(df_joint$Support, c("No support for climate-friendly products" ="No Support", "Support (15% lower price for climate-friendly products)"="Moderate Support", "Large support (30% lower price for climate-friendly products)"="Large Support"))


table(df_joint$Investments)
df_joint$Investments=revalue(df_joint$Investments, c("No investments"="No Investments", "Investments in public transport and e-mobility"="Moderate Investments", "Large investments in public transport and e-mobility"="Large Investments"))

table(df_joint$Standards)
df_joint$Standards=revalue(df_joint$Standards, c("No standards"="No Standards", "Standards for car producers (15% less emissions)"="Moderate Standards", "High standards for car producers (30% less emissions)"="High Standards"))

table(df_joint$Tax)

df_joint$Tax=revalue(df_joint$Tax, c("No CO2 tax"="No CO2 Tax", "CO2 tax (15% higher price for climate-damaging products)"="Moderate CO2 Tax", "High CO2 tax (30% higher price for climate-damaging products)"="High CO2 Tax"))


df_joint$Restrictions=revalue(df_joint$Restrictions, c("No restrictions"="No Restrictions", "Restrictions (1 day/week ban cars that run on fossil fuels from city centers)"="Moderate Restrictions Cars", "Restrictions (1 meat-free day/week in public cafeterias)"="Moderate Restrictions Meat","Strong restrictions (3 days/week ban cars that run on fossil fuels from city centers)"="Strong Restrictions Cars","Strong restrictions (3 meat-free days/week in public cafeterias)"="Strong Restrictions Meat" ))


#Estimate and Plot Differences in Marginal Means Germany
diff_mm_All_DE <- cj(subset(df_joint,country =="Germany"), choice_cor ~ Support + Investments+ Standards + Tax + Restrictions, id = ~id, estimate = "mm_diff", by = ~Governance)

BY <- unique(as.character(diff_mm_All_DE$BY))
tr <- lapply(BY, function(x) {
  d <- diff_mm_All_DE[diff_mm_All_DE$BY == x, ]
  t <- createTexreg(coef.names = as.character(d$level),
                    coef = d$estimate,
                    se = d$std.error,
                    pvalues = d$p,
                    model.name = x)
  return(t)
})
screenreg(tr)
htmlreg(tr, file ="DE_sample.html")
wordreg(tr, file ="DE_sample.docx")


diff_mm_All_DE_plot = plot (diff_mm_All_DE ,feature_headers = F, size = 3, width=3)+
  ggplot2::facet_grid(feature~BY,  scales = "free_y", space = "free", switch ="y") +
  theme(panel.border = element_rect(linetype = "blank"),
        panel.background = element_blank(), 
        axis.text.y = element_text(colour = "#515151", size = 12),
        axis.text.x = element_text(colour = "#091926", size = 12),
        axis.title = element_text(colour = "#091926", size = 12),
        panel.grid.major = element_line(colour = "grey", linetype = "dotted"),
        axis.ticks = element_blank(), 
        legend.position = "none",
        panel.spacing.y = unit(1, "lines"),
        strip.background= element_rect(color="white", size = 1, fill = "#f9f9f9"), 
        strip.text.y.left = element_text(angle = 0),
        strip.placement = "outside", strip.text.x = element_text(colour = "#091926", size = 12, face = "bold"),
        strip.text.y = element_text(colour = "#091926", size = 12, face = "bold")) +
  geom_point(size=2) +
  scale_color_manual(values = rep("#062f51", 9)) +scale_x_continuous(name = "German Sample: Estimated Differences in Marginal Means between Different Sources of Legitimation", limits = c(-0.1, 0.22))

ggsave("diff_mm_All_DE_plot.png", width = 30, height = 18,  units = "cm", dpi =300)



#Estimate and Plot Differences in AMCES Germany
diff_amces_All_DE <- cj(subset(df_joint,country =="Germany"), choice_cor ~ Support + Investments+ Standards + Tax + Restrictions, id = ~id, estimate = "amce_diff", by = ~Governance)

diff_amces_All_DE_plot =plot(rbind(diff_amces_All_DE)) + ggplot2::facet_wrap(~BY, ncol = 2L)

ggsave("diff_amces_All_DE.png", width = 36, height = 24,  units = "cm", dpi =300)



#Estimate and Plot Differences in Marginal Means USA

diff_mm_All_US <- cj(subset(df_joint,country =="USA"), choice_cor ~ Support + Investments+ Standards + Tax + Restrictions, id = ~id, estimate = "mm_diff", by = ~Governance)
diff_mm_All_US


BY <- unique(as.character(diff_mm_All_US$BY))
tr <- lapply(BY, function(x) {
  d <- diff_mm_All_US[diff_mm_All_US$BY == x, ]
  t <- createTexreg(coef.names = as.character(d$level),
                    coef = d$estimate,
                    se = d$std.error,
                    pvalues = d$p,
                    model.name = x)
  return(t)
})
screenreg(tr)
htmlreg(tr, file ="US_sample.html")
wordreg(tr, file ="US_sample.docx")


diff_mm_All_US_plot = plot (diff_mm_All_US ,feature_headers = F, size = 3, width=3)+
  ggplot2::facet_grid(feature~BY,  scales = "free_y", space = "free", switch ="y") +
  theme(panel.border = element_rect(linetype = "blank"),
        panel.background = element_blank(), 
        axis.text.y = element_text(colour = "#515151", size = 12),
        axis.text.x = element_text(colour = "#091926", size = 12),
        axis.title = element_text(colour = "#091926", size = 12),
        panel.grid.major = element_line(colour = "grey", linetype = "dotted"),
        axis.ticks = element_blank(), 
        legend.position = "none",
        panel.spacing.y = unit(1, "lines"),
        strip.background= element_rect(color="white", size = 1, fill = "#f9f9f9"), 
        strip.text.y.left = element_text(angle = 0),
        strip.placement = "outside", strip.text.x = element_text(colour = "#091926", size = 12, face = "bold"),
        strip.text.y = element_text(colour = "#091926", size = 12, face = "bold")) +
  geom_point(size=2) +
  scale_color_manual(values = rep("#062f51", 9)) +scale_x_continuous(name = "US Sample: Estimated Differences in Marginal Means between Different Sources of Legitimation", limits = c(-0.1, 0.2))

ggsave("diff_mm_All_US_plot.png", width = 30, height = 18,  units = "cm", dpi =300)


#Estimate and Plot Differences in AMCES USA
diff_amces_All_US <- cj(subset(df_joint,country =="USA"), choice_cor ~ Support + Investments+ Standards + Tax + Restrictions, id = ~id, estimate = "amce_diff", by = ~Governance)

diff_amces_All_US_plot =plot(rbind(diff_amces_All_US)) + ggplot2::facet_wrap(~BY, ncol = 2L)

ggsave("diff_amces_All_US.png", width = 36, height = 24,  units = "cm", dpi =300)



#Estimate and Plot Differences in Marginal Means Germany - Left and Right Median Split
diff_mm_All_DE_Left <- cj(subset(df_joint,country =="Germany" & Left_Right_Median_split =="Left"), choice_cor ~ Support + Investments+ Standards + Tax + Restrictions, id = ~id, estimate = "mm_diff", by = ~Governance)

BY <- unique(as.character(diff_mm_All_DE_Left$BY))
tr <- lapply(BY, function(x) {
  d <- diff_mm_All_DE_Left[diff_mm_All_DE_Left$BY == x, ]
  t <- createTexreg(coef.names = as.character(d$level),
                    coef = d$estimate,
                    se = d$std.error,
                    pvalues = d$p,
                    model.name = x)
  return(t)
})
screenreg(tr)
htmlreg(tr, file ="DE_sample_Left.html")
wordreg(tr, file ="DE_sample_Left.docx")


diff_mm_All_DE_Left_plot = plot (diff_mm_All_DE_Left ,feature_headers = F, size = 3, width=3)+
  ggplot2::facet_grid(feature~BY,  scales = "free_y", space = "free", switch ="y") +
  theme(panel.border = element_rect(linetype = "blank"),
        panel.background = element_blank(), 
        axis.text.y = element_text(colour = "#515151", size = 12),
        axis.text.x = element_text(colour = "#091926", size = 12),
        axis.title = element_text(colour = "#091926", size = 12),
        panel.grid.major = element_line(colour = "grey", linetype = "dotted"),
        axis.ticks = element_blank(), 
        legend.position = "none",
        panel.spacing.y = unit(1, "lines"),
        strip.background= element_rect(color="white", size = 1, fill = "#f9f9f9"), 
        strip.text.y.left = element_text(angle = 0),
        strip.placement = "outside", strip.text.x = element_text(colour = "#091926", size = 12, face = "bold"),
        strip.text.y = element_text(colour = "#091926", size = 12, face = "bold")) +
  geom_point(size=2) +
  scale_color_manual(values = rep("#062f51", 9)) +scale_x_continuous(name = "German Left Voter (Median Split): Estimated Differences in Marginal Means between Sources of Legitimation", limits = c(-0.25, 0.4))

ggsave("diff_mm_All_DE_Left_plot.png", width = 30, height = 18,  units = "cm", dpi =300)


diff_mm_All_DE_Right <- cj(subset(df_joint,country =="Germany" & Left_Right_Median_split =="Right"), choice_cor ~ Support + Investments+ Standards + Tax + Restrictions, id = ~id, estimate = "mm_diff", by = ~Governance)

BY <- unique(as.character(diff_mm_All_DE_Right$BY))
tr <- lapply(BY, function(x) {
  d <- diff_mm_All_DE_Right[diff_mm_All_DE_Right$BY == x, ]
  t <- createTexreg(coef.names = as.character(d$level),
                    coef = d$estimate,
                    se = d$std.error,
                    pvalues = d$p,
                    model.name = x)
  return(t)
})
screenreg(tr)
htmlreg(tr, file ="DE_sample_Right.html")
wordreg(tr, file ="DE_sample_Right.docx")


diff_mm_All_DE_Right_plot = plot (diff_mm_All_DE_Right ,feature_headers = F, size = 3, width=3)+
  ggplot2::facet_grid(feature~BY,  scales = "free_y", space = "free", switch ="y") +
  theme(panel.border = element_rect(linetype = "blank"),
        panel.background = element_blank(), 
        axis.text.y = element_text(colour = "#515151", size = 12),
        axis.text.x = element_text(colour = "#091926", size = 12),
        axis.title = element_text(colour = "#091926", size = 12),
        panel.grid.major = element_line(colour = "grey", linetype = "dotted"),
        axis.ticks = element_blank(), 
        legend.position = "none",
        panel.spacing.y = unit(1, "lines"),
        strip.background= element_rect(color="white", size = 1, fill = "#f9f9f9"), 
        strip.text.y.left = element_text(angle = 0),
        strip.placement = "outside", strip.text.x = element_text(colour = "#091926", size = 12, face = "bold"),
        strip.text.y = element_text(colour = "#091926", size = 12, face = "bold")) +
  geom_point(size=2) +
  scale_color_manual(values = rep("#062f51", 9)) +scale_x_continuous(name = "German Right Voter (Median Split): Estimated Differences in Marginal Means between Sources of Legitimation", limits = c(-0.25, 0.4))

ggsave("diff_mm_All_DE_Right_plot.png", width = 30, height = 18,  units = "cm", dpi =300)


#Estimate and Plot Differences in Marginal Means USA - Left and Right Median Split
diff_mm_All_US_Left <- cj(subset(df_joint,country =="USA" & Left_Right_Median_split =="Left"), choice_cor ~ Support + Investments+ Standards + Tax + Restrictions, id = ~id, estimate = "mm_diff", by = ~Governance)

BY <- unique(as.character(diff_mm_All_US_Left$BY))
tr <- lapply(BY, function(x) {
  d <- diff_mm_All_US_Left[diff_mm_All_US_Left$BY == x, ]
  t <- createTexreg(coef.names = as.character(d$level),
                    coef = d$estimate,
                    se = d$std.error,
                    pvalues = d$p,
                    model.name = x)
  return(t)
})
screenreg(tr)
htmlreg(tr, file ="US_sample_Left.html")
wordreg(tr, file ="US_sample_Left.docx")


diff_mm_All_US_Left_plot = plot (diff_mm_All_US_Left ,feature_headers = F, size = 3, width=3)+
  ggplot2::facet_grid(feature~BY,  scales = "free_y", space = "free", switch ="y") +
  theme(panel.border = element_rect(linetype = "blank"),
        panel.background = element_blank(), 
        axis.text.y = element_text(colour = "#515151", size = 12),
        axis.text.x = element_text(colour = "#091926", size = 12),
        axis.title = element_text(colour = "#091926", size = 12),
        panel.grid.major = element_line(colour = "grey", linetype = "dotted"),
        axis.ticks = element_blank(), 
        legend.position = "none",
        panel.spacing.y = unit(1, "lines"),
        strip.background= element_rect(color="white", size = 1, fill = "#f9f9f9"), 
        strip.text.y.left = element_text(angle = 0),
        strip.placement = "outsiUS", strip.text.x = element_text(colour = "#091926", size = 12, face = "bold"),
        strip.text.y = element_text(colour = "#091926", size = 12, face = "bold")) +
  geom_point(size=2) +
  scale_color_manual(values = rep("#062f51", 9)) +scale_x_continuous(name = "US Left Voter (Median Split): Estimated Differences in Marginal Means between Sources of Legitimation", limits = c(-0.25, 0.4))

ggsave("diff_mm_All_US_Left_plot.png", width = 30, height = 18,  units = "cm", dpi =300)


diff_mm_All_US_Right <- cj(subset(df_joint,country =="USA" & Left_Right_Median_split =="Right"), choice_cor ~ Support + Investments+ Standards + Tax + Restrictions, id = ~id, estimate = "mm_diff", by = ~Governance)

BY <- unique(as.character(diff_mm_All_US_Right$BY))
tr <- lapply(BY, function(x) {
  d <- diff_mm_All_US_Right[diff_mm_All_US_Right$BY == x, ]
  t <- createTexreg(coef.names = as.character(d$level),
                    coef = d$estimate,
                    se = d$std.error,
                    pvalues = d$p,
                    model.name = x)
  return(t)
})
screenreg(tr)
htmlreg(tr, file ="US_sample_Right.html")
wordreg(tr, file ="US_sample_Right.docx")


diff_mm_All_US_Right_plot = plot (diff_mm_All_US_Right ,feature_headers = F, size = 3, width=3)+
  ggplot2::facet_grid(feature~BY,  scales = "free_y", space = "free", switch ="y") +
  theme(panel.border = element_rect(linetype = "blank"),
        panel.background = element_blank(), 
        axis.text.y = element_text(colour = "#515151", size = 12),
        axis.text.x = element_text(colour = "#091926", size = 12),
        axis.title = element_text(colour = "#091926", size = 12),
        panel.grid.major = element_line(colour = "grey", linetype = "dotted"),
        axis.ticks = element_blank(), 
        legend.position = "none",
        panel.spacing.y = unit(1, "lines"),
        strip.background= element_rect(color="white", size = 1, fill = "#f9f9f9"), 
        strip.text.y.left = element_text(angle = 0),
        strip.placement = "outsiUS", strip.text.x = element_text(colour = "#091926", size = 12, face = "bold"),
        strip.text.y = element_text(colour = "#091926", size = 12, face = "bold")) +
  geom_point(size=2) +
  scale_color_manual(values = rep("#062f51", 9)) +scale_x_continuous(name = "US Right Voter (Median Split): Estimated Differences in Marginal Means between Sources of Legitimation", limits = c(-0.25, 0.4))

ggsave("diff_mm_All_US_Right_plot.png", width = 30, height = 18,  units = "cm", dpi =300)


#Prepare data and analysis of German descriptive survey###############

descriptives_DE$Mitspracherecht=revalue(descriptives_DE$Mitspracherecht, c("Stimme \u0081berhaupt nicht zu"="Completely disagree", "Stimme nicht zu"="Disagree", "Stimme eher nicht zu"="Disagree somewhat","Weder noch"="Neither nor","Stimme eher zu"="Agree somewhat","Stimme zu"="Agree","Stimme voll und ganz zu"="Completely Agree"))

descriptives_DE$Mitspracherecht <- factor(descriptives_DE$Mitspracherecht, levels = c("Completely disagree", "Disagree", "Disagree somewhat", "Neither nor","Agree somewhat", "Agree","Completely Agree" ))

Mitspracherecht_table <- prop.table(table(descriptives_DE$Mitspracherecht)) * 100
Mitspracherecht_table

Mitspracherecht_plot=ggplot(descriptives_DE, aes(x = Mitspracherecht)) + 
  geom_bar(aes(y = (..count..)/sum(..count..))) + 
  scale_y_continuous(labels = scales::percent_format()) +geom_text(stat='count', aes(label=scales::percent((..count..)/sum(..count..)), y= ((..count..)/sum(..count..))), vjust=1.5, color="white") +
  labs(title = "To what extent do you agree or disagree with the following statement?\nCitizens should have more say in German climate policy.", y = "Percentage", x = "Response")+
  theme(axis.text.y = element_text(colour = "#515151", size = 12),
        axis.text.x = element_text(colour = "#091926", size = 12),
        axis.title = element_text(colour = "#091926", size = 12))

ggsave("Mitspracherecht_plot.png", width = 32, height = 18,  units = "cm", dpi =300)

descriptives_DE$Buergerentscheide=revalue(descriptives_DE$Buergerentscheide, c("Stimme \u0081berhaupt nicht zu"="Completely disagree", "Stimme nicht zu"="Disagree", "Stimme eher nicht zu"="Disagree somewhat","Weder noch"="Neither nor","Stimme eher zu"="Agree somewhat","Stimme zu"="Agree","Stimme voll und ganz zu"="Completely Agree"))

descriptives_DE$Buergerentscheide <- factor(descriptives_DE$Buergerentscheide, levels = c("Completely disagree", "Disagree", "Disagree somewhat", "Neither nor","Agree somewhat", "Agree","Completely Agree" ))

Buergerentscheide_table <- prop.table(table(descriptives_DE$Buergerentscheide)) * 100
Buergerentscheide_table

Buergerentscheide_plot=ggplot(descriptives_DE, aes(x = Buergerentscheide)) + 
  geom_bar(aes(y = (..count..)/sum(..count..))) + 
  scale_y_continuous(labels = scales::percent_format()) +geom_text(stat='count', aes(label=scales::percent((..count..)/sum(..count..)), y= ((..count..)/sum(..count..))), vjust=1.5, color="white") +
  labs(title = "To what extent do you agree or disagree with the following statement?\nFor important decisions on climate protection in Germany, there should be citizen referendums that are binding for politicians to implement.", y = "Percentage", x = "Response")+
  theme(axis.text.y = element_text(colour = "#515151", size = 12),
        axis.text.x = element_text(colour = "#091926", size = 12),
        axis.title = element_text(colour = "#091926", size = 12))

ggsave("Buergerentscheide_plot.png", width = 32, height = 18,  units = "cm", dpi =300)


descriptives_DE$Klimabuergerrat=revalue(descriptives_DE$Klimabuergerrat, c("Stimme \u0081berhaupt nicht zu"="Completely disagree", "Stimme nicht zu"="Disagree", "Stimme eher nicht zu"="Disagree somewhat","Weder noch"="Neither nor","Stimme eher zu"="Agree somewhat","Stimme zu"="Agree","Stimme voll und ganz zu"="Completely Agree"))

descriptives_DE$Klimabuergerrat <- factor(descriptives_DE$Klimabuergerrat, levels = c("Completely disagree", "Disagree", "Disagree somewhat", "Neither nor","Agree somewhat", "Agree","Completely Agree" ))

Klimabuergerrat_table <- prop.table(table(descriptives_DE$Klimabuergerrat)) * 100
Klimabuergerrat_table

Klimabuergerrat_plot=ggplot(descriptives_DE, aes(x = Klimabuergerrat)) + 
  geom_bar(aes(y = (..count..)/sum(..count..))) + 
  scale_y_continuous(labels = scales::percent_format()) +geom_text(stat='count', aes(label=scales::percent((..count..)/sum(..count..)), y= ((..count..)/sum(..count..))), vjust=1.5, color="white") +
  labs(title = "To what extent do you agree or disagree with the following statement?\nI am in favor of introducing a climate citizens' council in Germany.", y = "Percentage", x = "Response")+
  theme(axis.text.y = element_text(colour = "#515151", size = 12),
        axis.text.x = element_text(colour = "#091926", size = 12),
        axis.title = element_text(colour = "#091926", size = 12))

ggsave("Klimabuergerrat_plot.png", width = 32, height = 18,  units = "cm", dpi =300)


descriptives_DE$InformationenBundesregierung=revalue(descriptives_DE$InformationenBundesregierung, c("Stimme \u0081berhaupt nicht zu"="Completely disagree", "Stimme nicht zu"="Disagree", "Stimme eher nicht zu"="Disagree somewhat","Weder noch"="Neither nor","Stimme eher zu"="Agree somewhat","Stimme zu"="Agree","Stimme voll und ganz zu"="Completely Agree"))

descriptives_DE$InformationenBundesregierung <- factor(descriptives_DE$InformationenBundesregierung, levels = c("Completely disagree", "Disagree", "Disagree somewhat", "Neither nor","Agree somewhat", "Agree","Completely Agree" ))

InformationenBundesregierung_table <- prop.table(table(descriptives_DE$InformationenBundesregierung)) * 100
InformationenBundesregierung_table

InformationenBundesregierung_plot=ggplot(descriptives_DE, aes(x = InformationenBundesregierung)) + 
  geom_bar(aes(y = (..count..)/sum(..count..))) + 
  scale_y_continuous(labels = scales::percent_format()) +geom_text(stat='count', aes(label=scales::percent((..count..)/sum(..count..)), y= ((..count..)/sum(..count..))), vjust=1.5, color="white") +
  labs(title = "To what extent do you agree or disagree with the following statement?\nInformation from the federal government cannot be trusted.", y = "Percentage", x = "Response")+
  theme(axis.text.y = element_text(colour = "#515151", size = 12),
        axis.text.x = element_text(colour = "#091926", size = 12),
        axis.title = element_text(colour = "#091926", size = 12))

ggsave("InformationenBundesregierung_plot.png", width = 32, height = 18,  units = "cm", dpi =300)

descriptives_DE$InformationenKlimawissenschaft=revalue(descriptives_DE$InformationenKlimawissenschaft, c("Stimme \u0081berhaupt nicht zu"="Completely disagree", "Stimme nicht zu"="Disagree", "Stimme eher nicht zu"="Disagree somewhat","Weder noch"="Neither nor","Stimme eher zu"="Agree somewhat","Stimme zu"="Agree","Stimme voll und ganz zu"="Completely Agree"))

descriptives_DE$InformationenKlimawissenschaft <- factor(descriptives_DE$InformationenKlimawissenschaft, levels = c("Completely disagree", "Disagree", "Disagree somewhat", "Neither nor","Agree somewhat", "Agree","Completely Agree" ))

InformationenKlimawissenschaft_table <- prop.table(table(descriptives_DE$InformationenKlimawissenschaft)) * 100
InformationenKlimawissenschaft_table

InformationenKlimawissenschaft_plot=ggplot(descriptives_DE, aes(x = InformationenKlimawissenschaft)) + 
  geom_bar(aes(y = (..count..)/sum(..count..))) + 
  scale_y_continuous(labels = scales::percent_format()) +geom_text(stat='count', aes(label=scales::percent((..count..)/sum(..count..)), y= ((..count..)/sum(..count..))), vjust=1.5, color="white") +
  labs(title = "To what extent do you agree or disagree with the following statement?\nInformation from climate scientists is not trustworthy.", y = "Percentage", x = "Response")+
  theme(axis.text.y = element_text(colour = "#515151", size = 12),
        axis.text.x = element_text(colour = "#091926", size = 12),
        axis.title = element_text(colour = "#091926", size = 12))

ggsave("InformationenKlimawissenschaft_plot.png", width = 32, height = 18,  units = "cm", dpi =300)


descriptives_DE$EinflussUnternehmen=revalue(descriptives_DE$EinflussUnternehmen, c("Stimme \u0081berhaupt nicht zu"="Completely disagree", "Stimme nicht zu"="Disagree", "Stimme eher nicht zu"="Disagree somewhat","Weder noch"="Neither nor","Stimme eher zu"="Agree somewhat","Stimme zu"="Agree","Stimme voll und ganz zu"="Completely Agree"))

descriptives_DE$EinflussUnternehmen <- factor(descriptives_DE$EinflussUnternehmen, levels = c("Completely disagree", "Disagree", "Disagree somewhat", "Neither nor","Agree somewhat", "Agree","Completely Agree" ))

EinflussUnternehmen_table <- prop.table(table(descriptives_DE$EinflussUnternehmen)) * 100
EinflussUnternehmen_table

EinflussUnternehmen_plot=ggplot(descriptives_DE, aes(x = EinflussUnternehmen)) + 
  geom_bar(aes(y = (..count..)/sum(..count..))) + 
  scale_y_continuous(labels = scales::percent_format()) +geom_text(stat='count', aes(label=scales::percent((..count..)/sum(..count..)), y= ((..count..)/sum(..count..))), vjust=1.5, color="white") +
  labs(title = "To what extent do you agree or disagree with the following statement?\nCompanies have too much influence and say in German climate policy.", y = "Percentage", x = "Response")+
  theme(axis.text.y = element_text(colour = "#515151", size = 12),
        axis.text.x = element_text(colour = "#091926", size = 12),
        axis.title = element_text(colour = "#091926", size = 12))

ggsave("EinflussUnternehmen_plot.png", width = 32, height = 18,  units = "cm", dpi =300)


descriptives_DE$BundesregierungHandel=revalue(descriptives_DE$BundesregierungHandel, c("Stimme \u0081berhaupt nicht zu"="Completely disagree", "Stimme nicht zu"="Disagree", "Stimme eher nicht zu"="Disagree somewhat","Weder noch"="Neither nor","Stimme eher zu"="Agree somewhat","Stimme zu"="Agree","Stimme voll und ganz zu"="Completely Agree"))

descriptives_DE$BundesregierungHandel <- factor(descriptives_DE$BundesregierungHandel, levels = c("Completely disagree", "Disagree", "Disagree somewhat", "Neither nor","Agree somewhat", "Agree","Completely Agree" ))

BundesregierungHandel_table <- prop.table(table(descriptives_DE$BundesregierungHandel)) * 100
BundesregierungHandel_table

BundesregierungHandel_plot=ggplot(descriptives_DE, aes(x = BundesregierungHandel)) + 
  geom_bar(aes(y = (..count..)/sum(..count..))) + 
  scale_y_continuous(labels = scales::percent_format()) +geom_text(stat='count', aes(label=scales::percent((..count..)/sum(..count..)), y= ((..count..)/sum(..count..))), vjust=1.5, color="white") +
  labs(title = "To what extent do you agree or disagree with the following statement?\nThe federal government acts in the best interests of the entire population, e.g. with regard to climate protection.", y = "Percentage", x = "Response")+
  theme(axis.text.y = element_text(colour = "#515151", size = 12),
        axis.text.x = element_text(colour = "#091926", size = 12),
        axis.title = element_text(colour = "#091926", size = 12))

ggsave("BundesregierungHandel_plot.png", width = 32, height = 18,  units = "cm", dpi =300)


descriptives_DE$KlimawissenschaftInteressen=revalue(descriptives_DE$KlimawissenschaftInteressen, c("Stimme \u0081berhaupt nicht zu"="Completely disagree", "Stimme nicht zu"="Disagree", "Stimme eher nicht zu"="Disagree somewhat","Weder noch"="Neither nor","Stimme eher zu"="Agree somewhat","Stimme zu"="Agree","Stimme voll und ganz zu"="Completely Agree"))

descriptives_DE$KlimawissenschaftInteressen <- factor(descriptives_DE$KlimawissenschaftInteressen, levels = c("Completely disagree", "Disagree", "Disagree somewhat", "Neither nor","Agree somewhat", "Agree","Completely Agree" ))

KlimawissenschaftInteressen_table <- prop.table(table(descriptives_DE$KlimawissenschaftInteressen)) * 100
KlimawissenschaftInteressen_table

KlimawissenschaftInteressen_plot=ggplot(descriptives_DE, aes(x = KlimawissenschaftInteressen)) + 
  geom_bar(aes(y = (..count..)/sum(..count..))) + 
  scale_y_continuous(labels = scales::percent_format()) +geom_text(stat='count', aes(label=scales::percent((..count..)/sum(..count..)), y= ((..count..)/sum(..count..))), vjust=1.5, color="white") +
  labs(title = "To what extent do you agree or disagree with the following statement?\nClimate scientists are guided by interests and deliberately exaggerate the climate problem.
", y = "Percentage", x = "Response")+
  theme(axis.text.y = element_text(colour = "#515151", size = 12),
        axis.text.x = element_text(colour = "#091926", size = 12),
        axis.title = element_text(colour = "#091926", size = 12))

ggsave("KlimawissenschaftInteressen_plot.png", width = 32, height = 18,  units = "cm", dpi =300)

descriptives_DE$BundesregierungKommunikation=revalue(descriptives_DE$BundesregierungKommunikation, c("Stimme \u0081berhaupt nicht zu"="Completely disagree", "Stimme nicht zu"="Disagree", "Stimme eher nicht zu"="Disagree somewhat","Weder noch"="Neither nor","Stimme eher zu"="Agree somewhat","Stimme zu"="Agree","Stimme voll und ganz zu"="Completely Agree"))

descriptives_DE$BundesregierungKommunikation <- factor(descriptives_DE$BundesregierungKommunikation, levels = c("Completely disagree", "Disagree", "Disagree somewhat", "Neither nor","Agree somewhat", "Agree","Completely Agree" ))

BundesregierungKommunikation_table <- prop.table(table(descriptives_DE$BundesregierungKommunikation)) * 100
BundesregierungKommunikation_table

BundesregierungKommunikation_plot=ggplot(descriptives_DE, aes(x = BundesregierungKommunikation)) + 
  geom_bar(aes(y = (..count..)/sum(..count..))) + 
  scale_y_continuous(labels = scales::percent_format()) +geom_text(stat='count', aes(label=scales::percent((..count..)/sum(..count..)), y= ((..count..)/sum(..count..))), vjust=1.5, color="white") +
  labs(title = "To what extent do you agree or disagree with the following statement?\nThe German government communicates its climate policy clearly and transparently.", y = "Percentage", x = "Response")+
  theme(axis.text.y = element_text(colour = "#515151", size = 12),
        axis.text.x = element_text(colour = "#091926", size = 12),
        axis.title = element_text(colour = "#091926", size = 12))

ggsave("BundesregierungKommunikation_plot.png", width = 32, height = 18,  units = "cm", dpi =300)

descriptives_DE$Klimaziel=revalue(descriptives_DE$Klimaziel, c("Stimme \u0081berhaupt nicht zu"="Completely disagree", "Stimme nicht zu"="Disagree", "Stimme eher nicht zu"="Disagree somewhat","Weder noch"="Neither nor","Stimme eher zu"="Agree somewhat","Stimme zu"="Agree","Stimme voll und ganz zu"="Completely Agree"))

descriptives_DE$Klimaziel <- factor(descriptives_DE$Klimaziel, levels = c("Completely disagree", "Disagree", "Disagree somewhat", "Neither nor","Agree somewhat", "Agree","Completely Agree" ))

Klimaziel_table <- prop.table(table(descriptives_DE$Klimaziel)) * 100
Klimaziel_table

Klimaziel_plot=ggplot(descriptives_DE, aes(x = Klimaziel)) + 
  geom_bar(aes(y = (..count..)/sum(..count..))) + 
  scale_y_continuous(labels = scales::percent_format()) +geom_text(stat='count', aes(label=scales::percent((..count..)/sum(..count..)), y= ((..count..)/sum(..count..))), vjust=1.5, color="white") +
  labs(title = "To what extent do you agree or disagree with the following statement?\nI believe that Germany will achieve its climate target for 2030 (= 55% reduction in emissions of climate-damaging gases compared with 1990).", y = "Percentage", x = "Response")+
  theme(axis.text.y = element_text(colour = "#515151", size = 12),
        axis.text.x = element_text(colour = "#091926", size = 12),
        axis.title = element_text(colour = "#091926", size = 12))

ggsave("Klimaziel_plot.png", width = 32, height = 18,  units = "cm", dpi =300)


descriptives_DE$KlimapolitikWirksam=revalue(descriptives_DE$KlimapolitikWirksam, c("Stimme \u0081berhaupt nicht zu"="Completely disagree", "Stimme nicht zu"="Disagree", "Stimme eher nicht zu"="Disagree somewhat","Weder noch"="Neither nor","Stimme eher zu"="Agree somewhat","Stimme zu"="Agree","Stimme voll und ganz zu"="Completely Agree"))

descriptives_DE$KlimapolitikWirksam <- factor(descriptives_DE$KlimapolitikWirksam, levels = c("Completely disagree", "Disagree", "Disagree somewhat", "Neither nor","Agree somewhat", "Agree","Completely Agree" ))

KlimapolitikWirksam_table <- prop.table(table(descriptives_DE$KlimapolitikWirksam)) * 100
KlimapolitikWirksam_table

KlimapolitikWirksam_plot=ggplot(descriptives_DE, aes(x = KlimapolitikWirksam)) + 
  geom_bar(aes(y = (..count..)/sum(..count..))) + 
  scale_y_continuous(labels = scales::percent_format()) +geom_text(stat='count', aes(label=scales::percent((..count..)/sum(..count..)), y= ((..count..)/sum(..count..))), vjust=1.5, color="white") +
  labs(title = "To what extent do you agree or disagree with the following statement?\nI think that the German climate policy is adequate and effective for climate protection.", y = "Percentage", x = "Response")+
  theme(axis.text.y = element_text(colour = "#515151", size = 12),
        axis.text.x = element_text(colour = "#091926", size = 12),
        axis.title = element_text(colour = "#091926", size = 12))

ggsave("KlimapolitikWirksam_plot.png", width = 32, height = 18,  units = "cm", dpi =300)


descriptives_DE$BeitragMitbürger=revalue(descriptives_DE$BeitragMitbürger, c("Stimme \u0081berhaupt nicht zu"="Completely disagree", "Stimme nicht zu"="Disagree", "Stimme eher nicht zu"="Disagree somewhat","Weder noch"="Neither nor","Stimme eher zu"="Agree somewhat","Stimme zu"="Agree","Stimme voll und ganz zu"="Completely Agree"))

descriptives_DE$BeitragMitbürger <- factor(descriptives_DE$BeitragMitbürger, levels = c("Completely disagree", "Disagree", "Disagree somewhat", "Neither nor","Agree somewhat", "Agree","Completely Agree" ))

BeitragMitbürger_table <- prop.table(table(descriptives_DE$BeitragMitbürger)) * 100
BeitragMitbürger_table

BeitragMitbürger_plot=ggplot(descriptives_DE, aes(x = BeitragMitbürger)) + 
  geom_bar(aes(y = (..count..)/sum(..count..))) + 
  scale_y_continuous(labels = scales::percent_format()) +geom_text(stat='count', aes(label=scales::percent((..count..)/sum(..count..)), y= ((..count..)/sum(..count..))), vjust=1.5, color="white") +
  labs(title = "To what extent do you agree or disagree with the following statement?\nI believe that my fellow citizens in Germany will do their fair share to protect the climate.", y = "Percentage", x = "Response")+
  theme(axis.text.y = element_text(colour = "#515151", size = 12),
        axis.text.x = element_text(colour = "#091926", size = 12),
        axis.title = element_text(colour = "#091926", size = 12))

ggsave("BeitragMitbürger_plot.png", width = 32, height = 18,  units = "cm", dpi =300)


descriptives_DE$Altersklasse_f = as.factor(descriptives_DE$Altersklasse)
descriptives_DE$Age=revalue(descriptives_DE$Altersklasse_f, c("2"="18-29 years", "3"="30-39 years", "4"="40-49 years","5"="50-59 years","6"="60-69 years","7"="70 years or older"))

Age_table <- prop.table(table(descriptives_DE$Age)) * 100
Age_table


descriptives_DE$Geschlecht_f = as.factor(descriptives_DE$Geschlecht)
descriptives_DE$Gender=revalue(descriptives_DE$Geschlecht_f, c("1"="Male", "2"="Female"))
Gender_table <- prop.table(table(descriptives_DE$Gender)) * 100
Gender_table

descriptives_DE$Bildungsabschluss_f = as.factor(descriptives_DE$Bildungsabschluss)
descriptives_DE$Education=revalue(descriptives_DE$Bildungsabschluss_f, c("1"="Kein Abschluss/Haupt-/Volksschulabschluss", "2"="Realschulabschluss/Mittlere Reife", "3" = "(Fach-)Hochschulreife/Abitur ohne Studium", "4" ="(Fach-) Hochschulabschluss"))
Education_table <- prop.table(table(descriptives_DE$Education)) * 100
Education_table


descriptives_DE$Bundesland_f = as.factor(descriptives_DE$Bundesland)
descriptives_DE$Region=revalue(descriptives_DE$Bundesland_f, c("1"="Baden-Württemberg", "2"="Bayern", "3" = "Berlin", "4" ="Brandenburg", "5" ="Bremen", "6" ="Hamburg", "7" ="Hessen", "8" ="Mecklenburg-Vorpommern", "9" ="Niedersachsen", "10" ="Nordrhein-Westfalen", "11" ="Rheinland-Pfalz", "12" ="Saarland", "13" ="Sachsen", "14" ="Sachsen-Anhalt", "15" ="Schleswig-Holstein", "16" ="Thüringen"))
Region_table <- prop.table(table(descriptives_DE$Region)) * 100
Region_table
